//
//  PersonVC.m
//  SchoolCircle
//
//  Created by 战立军 on 16/5/27.
//  Copyright © 2016年 战立军. All rights reserved.
//

#import "PersonVC.h"

@interface PersonVC ()<UITableViewDelegate,UITableViewDataSource>
{
    UIImageView *_headImage;
    UILabel *_username;
    
    UIButton *_changePersoinfoBtn;
    UIButton *_personSetBtn;
    
    UITableView *_tabeView;
    
    UIButton *_exitBtn;
}
@end

@implementation PersonVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view setBackgroundColor:[UIColor whiteColor]];
    [self setNav];
    [self addContentView];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark 导航栏
- (void)setNav
{
    self.title = @"我";
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"uitabr"]];
    // 设置导航默认标题的颜色及字体大小
    self.navigationController.navigationBar.titleTextAttributes = @{UITextAttributeTextColor: [UIColor whiteColor],
                                                                    UITextAttributeFont : [UIFont boldSystemFontOfSize:18]};
}


- (void)addContentView
{
    if ([UIDevice currentDevice].systemVersion.floatValue >= 7) {
        self.edgesForExtendedLayout = UIRectEdgeNone;
    }

    _headImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 80, 80)];
    _headImage.layer.cornerRadius = 40;
    [self.view addSubview:_headImage];
    
    _username = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_headImage.frame)+5, 0, [UIUTils getWindowWidth]-80-40, 40)];
    _username.adjustsFontSizeToFitWidth = YES;
    [self.view addSubview:_username];
    
    _changePersoinfoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _changePersoinfoBtn.frame = CGRectMake(0, CGRectGetMaxY(_headImage.frame), [UIUTils getWindowWidth]/2.0, 50);
    [_changePersoinfoBtn setTitle:@"编辑个人资料" forState:UIControlStateNormal];
    [_changePersoinfoBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    _changePersoinfoBtn.layer.borderWidth = 1;
    _changePersoinfoBtn.layer.borderColor = [UIColor lightGrayColor].CGColor;
    [self.view addSubview:_changePersoinfoBtn];
    
    _personSetBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _personSetBtn.frame = CGRectMake(CGRectGetMaxX(_changePersoinfoBtn.frame), CGRectGetMaxY(_headImage.frame), [UIUTils getWindowWidth]/2.0, 50);
    [_personSetBtn setTitle:@"隐私设置" forState:UIControlStateNormal];
    [_personSetBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    _personSetBtn.layer.borderWidth =1;
    _personSetBtn.layer.borderColor = [UIColor lightGrayColor].CGColor;
    [self.view addSubview:_personSetBtn];
    
    _tabeView = [[UITableView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_personSetBtn.frame)+20, [UIUTils getWindowWidth], [UIUTils getWindowHeight]-CGRectGetMaxY(_personSetBtn.frame)-210)];
    _tabeView.tableFooterView = [[UIView alloc] init];
    _tabeView.delegate =self;
    _tabeView.dataSource = self;
    [self.view addSubview:_tabeView];
    
    _exitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _exitBtn.frame = CGRectMake(30, CGRectGetMaxY(_tabeView.frame)+10, [UIUTils getWindowWidth]-30*2, 40);
    [_exitBtn setTitle:@"退出" forState:UIControlStateNormal];
    [_exitBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    _exitBtn.backgroundColor = [UIColor redColor];
    [self.view addSubview:_exitBtn];
}

- (void)setContentView
{
    
}
#pragma mark 操作

- (void)exitButtonPress
{}

#pragma mark UITableViewDataSource

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 4;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdet = @"mycell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdet];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdet];
    }
    
    
    switch (indexPath.row) {
        case 0:
        {
            cell.imageView.image = [UIImage imageNamed:@"collction"];
            cell.textLabel.text = @"收藏";
        }
            break;
        case 1:
        {
            cell.imageView.image = [UIImage imageNamed:@"money"];
            cell.textLabel.text = @"钱包";
        }

        
            break;
        case 2:
        {
            cell.imageView.image = [UIImage imageNamed:@"hi"];
            cell.textLabel.text = @"好友请求";
        }
            break;
        case 3:
        {
            cell.imageView.image = [UIImage imageNamed:@"authenuser"];
            cell.textLabel.text = @"认证用户";
        }
                   break;
            
        default:
            break;
    }

    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
}

#pragma mark UITableViewDelegate

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

@end
